package com.fll.fangyishare.service.impl;

import com.fll.fangyicommon.entity.share.Oss;
import com.fll.fangyishare.dao.OssDao;
import com.fll.fangyishare.service.OssService;
import lombok.extern.slf4j.Slf4j;
import org.apache.tomcat.jni.OS;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author fll
 * create 2023/3/25
 */
@Service
@Slf4j
public class OssServiceImpl implements OssService {

    @Autowired
    private OssDao ossDao;

    /**
     * 插入说说图片集合
     * @return
     */
    @Override
    public Integer addShareOss(List<Oss> ossList){
        Integer num = ossDao.addShareOss(ossList);
        if (num != 0){
            log.info("插入share图片成功，记录数===>{}", num);
            return num;
        }
        return -1;
    }

    /**
     * 返回share的oss图
     * @param shareId
     * @return
     */
    @Override
    public ArrayList<String> getShareOss(Integer shareId) {
        ArrayList<String> shareOss = ossDao.getShareOss(shareId);
        if (shareOss == null && shareOss.size() == 0){
            log.warn("该share的oss图为空");
            return null;
        }
        log.info("shareId===>{},该share的oss图===>{}", shareId, shareOss);
        return shareOss;
    }
}
